package playingCAEDS;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

class Card{
    private String color;
    private String number;

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }
    public Card() {

    }

    public Card(String color, String number) {
        this.color = color;
        this.number = number;
    }

    @Override
    public String toString() {
        return color + " " + number ;
    }
}
public class CarDemo {
    public static  String[] color = {"♠","♥","♣","♦"};
    public static String[] number = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"};


    public static List<Card> buyCard() {
        List<Card> cards = new ArrayList<>();
        for (int i = 0; i < 13; i++) {
            for (int j = 0; j < 4; j++) {
                Card card = new Card(color[j],number[i]);
                cards.add(card);
            }
        }
        return cards;
    }
    public void shuffle(List<Card> cards) {
        for (int i = cards.size() - 1; i > 0 ; i--) {
            Random random =new Random();
            int index =random.nextInt(i);
            swap(cards,index,i);


        }
    }
    public void swap(List<Card> cards,int i,int j){

        Card tmp = cards.get(i);
        cards.set(i,cards.get(j));
        cards.set(j,tmp);
    }
    public List<List<Card>> person(List<Card> cards) {
        List<Card> p1 = new ArrayList<>();
        List<Card> p2 = new ArrayList<>();
        List<Card> p3 = new ArrayList<>();

        List<List<Card>> ps =new ArrayList<>();
        ps.add(p1);
        ps.add(p2);
        ps.add(p3);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cards.remove(0);
                ps.get(j).add(card);
            }
        }

        return ps;
    }


}
